﻿namespace AgileZen.Models
{
    using System.Collections.Generic;
    using System.Runtime.Serialization;
    
    [DataContract(Name = "story")]
    public class Story : AgileZenModel
    {
        private int _id;
        private string _text;
        private string _size;
        private string _color;
        private bool _ready;
        private bool _blocked;
        private int _phaseindex;
        private Phase _phase;
        private Person _creator;
        private Person _owner;
        private string _details;
        private ICollection<Tag> _tags;
        private ICollection<Task> _tasks;

        [DataMember(Name = "id", Order = 3, EmitDefaultValue = false)]
        public int Id
        {
            get { return _id; }
            set { _id = value; NotifyPropertyChanged("Id"); }
        }

        public bool ShouldSerializeId()
        {
            return PropertiesChanged.Contains("Id");
        }

        [DataMember(Name = "text", Order = 9, EmitDefaultValue = false)]
        public string Text 
        {
            get { return _text; }
            set { _text = value; NotifyPropertyChanged("Text"); } 
        }

        public bool ShouldSerializeText()
        {
            return PropertiesChanged.Contains("Text");
        }

        [DataMember(Name = "size", Order = 8, EmitDefaultValue = false)]
        public string Size
        {
            get { return _size; }
            set { _size = value; NotifyPropertyChanged("Size"); }
        }

        public bool ShouldSerializeSize()
        {
            return PropertiesChanged.Contains("Size");
        }

        [DataMember(Name = "color", Order = 1, EmitDefaultValue = false)]
        public string Color 
        {
            get { return _color; }
            set { _color = value; NotifyPropertyChanged("Color"); }
        }

        public bool ShouldSerializeColor()
        {
            return PropertiesChanged.Contains("Color");
        }

        [DataMember(Name = "ready", Order = 7, EmitDefaultValue = false)]
        public bool Ready
        {
            get { return _ready; }
            set { _ready = value; NotifyPropertyChanged("Ready"); }
        }

        public bool ShouldSerializeReady()
        {
            return PropertiesChanged.Contains("Ready");
        }

        [DataMember(Name = "blocked", Order = 0, EmitDefaultValue = false)]
        public bool Blocked
        {
            get { return _blocked; }
            set { _blocked = value; NotifyPropertyChanged("Blocked"); }
        }

        public bool ShouldSerializeBlocked()
        {
            return PropertiesChanged.Contains("Blocked");
        }

        [DataMember(Name = "phaseIndex", Order = 6, EmitDefaultValue = false)]
        public int PhaseIndex
        {
            get { return _phaseindex; }
            set { _phaseindex = value; NotifyPropertyChanged("PhaseIndex"); }
        }

        public bool ShouldSerializePhaseIndex()
        {
            return PropertiesChanged.Contains("PhaseIndex");
        }

        [DataMember(Name = "phase", Order = 5, EmitDefaultValue = false)]
        public Phase Phase
        {
            get { return _phase; }
            set { _phase = value; NotifyPropertyChanged("Phase"); }
        }

        public bool ShouldSerializePhase()
        {
            return PropertiesChanged.Contains("Phase");
        }

        [DataMember(Name = "creator", Order = 2, EmitDefaultValue = false)]
        public Person Creator
        {
            get { return _creator; }
            set { _creator = value; NotifyPropertyChanged("Creator"); }
        }

        public bool ShouldSerializeCreator()
        {
            return PropertiesChanged.Contains("Creator");
        }

        [DataMember(Name = "owner", Order = 4, EmitDefaultValue = false)]
        public Person Owner
        {
            get { return _owner; }
            set { _owner = value; NotifyPropertyChanged("Owner"); }
        }

        public bool ShouldSerializeOwner()
        {
            return PropertiesChanged.Contains("Owner");
        }

        [DataMember(Name = "details", Order = 10, EmitDefaultValue = false)]
        public string Details
        {
            get { return _details; }
            set { _details = value; NotifyPropertyChanged("Details"); }
        }

        public bool ShouldSerializeDetails()
        {
            return PropertiesChanged.Contains("Details");
        }

        [DataMember(Name = "tags", Order = 11, EmitDefaultValue = false)]
        public ICollection<Tag> Tags
        {
            get { return _tags; }
            set { _tags = value; NotifyPropertyChanged("Tags"); }
        }

        public bool ShouldSerializeTags()
        {
            return PropertiesChanged.Contains("Tags");
        }

        [DataMember(Name = "tasks", Order = 11, EmitDefaultValue = false)]
        public ICollection<Task> Tasks
        {
            get { return _tasks; }
            set { _tasks = value; NotifyPropertyChanged("Tasks"); }
        }

        public bool ShouldSerializeTasks()
        {
            return PropertiesChanged.Contains("Tasks");
        }

        public static class Enrichments
        {
            public const string Details = "details";
            public const string Tags = "tags";
            public const string Tasks = "tasks";
        }
    }
}
